jq(function(){
	//colorizeTable("menutable", "uwrTable", "seheader uwrZebraEven", "uwrZebraOdd", "uwrZebraOdd", "uwrTb");

	colorizeTable("zebratable",  	   "table", 			"tableColorSwitch", "tableRowEven", 		   "tableRowOdd", 		   "tableCell")	
	colorizeTable("zebratableLabeled", "tableContainer",    "", 				"tableContainerRowEven",   "tableContainerRowOdd", "tableContainerCell")

	jq(".sorted").tablesorter();
	jq(".sorted").bind("sortEnd",function() { 
        colorizeTable("zebratable", "table", "tableColorSwitch", "tableRowEven", "tableRowOdd", "tableCell")
    });
});

function colorizeTable(cssClass, tableclass, switchclass, evenclass, oddclass, cellclass) {
	jq("." + cssClass).each(function(){
	    jq(this).addClass(tableclass);
		jq(this).children("thead").children("tr").addClass(evenclass);
		jq(this).children("thead").children("tr").each(function(){
			jq(this).children("th").each(function(){
			    jq(this).addClass(cellclass);    
			})
		})
		var even = false;
		jq(this).children("tbody").children("tr").each(function(){
		    if(even) {
		        jq(this).removeClass(evenclass).removeClass(oddclass).addClass(evenclass);
		    } else {
		        jq(this).removeClass(evenclass).removeClass(oddclass).addClass(oddclass);
		    }
		    even = !even;
			jq(this).children("td").each(function(){
			    jq(this).addClass(cellclass + " " + switchclass);    
			})
		})
	})
}
